package com.jiayi.microservice.service;

import com.jiayi.microservice.pojo.Item;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Item Service
 * @author: CONCENTRATE
 * @time: 2018/11/3.
 */
@Service
public class ItemService {

    private static final Map<Long, Item> ITEM_MAP = new HashMap<>(5);

    static {
        //data create
        ITEM_MAP.put(1L, new Item(1L,"title1", "http://pic/1", 100.00));
        ITEM_MAP.put(2L, new Item(2L,"title2", "http://pic/2", 200.00));
        ITEM_MAP.put(3L, new Item(3L,"title3", "http://pic/3", 300.00));
        ITEM_MAP.put(4L, new Item(4L,"title4", "http://pic/4", 400.00));
        ITEM_MAP.put(5L, new Item(5L,"title5", "http://pic/5", 500.00));
    }

    /**
     * queryItemById
     * @param id
     * @return
     */
    public Item queryItemById(Long id){
        return ITEM_MAP.get(id);
    }

}
